package samples.microPicasa;

import android.util.Log;

import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;

import myh.feed.Feed;
import myh.feed.FeedEntry;
import myh.feed.FeedList;
import myh.feed.GoogleMetaFeed;
import android.app.Activity;
import android.os.Bundle;

public class MicroPicasaActivity extends Activity
{ private static final String TAG="samples.microPicasa.MicroPicasaActivity";
  private static final boolean VERBOSE=true;
  private static final boolean DEBUG=true;
  
  /** Called when the activity is first created. */
  public void onCreate(Bundle icicle)
  { super.onCreate(icicle);
    setContentView(R.layout.main);
        
    new Thread() { public void run() { TestFeedAPI(); } }.start(); // TODO: TEST
        
  }
    
  private void TestFeedAPI() // NOTE: Private Constructor
  { GoogleMetaFeed googleMetaFeed=null;
    String userId="o.myhre";
  	String password="******";
  	try
  	{ googleMetaFeed=GoogleMetaFeed.createPicasaAlbumList(new FeedList(),userId,password);
  	} catch(Exception e) { e.printStackTrace(); }
  	
    if(VERBOSE)
    { Log.v(TAG,"*************** FEED LIST *****************");
  	  for(Enumeration<Feed> e=googleMetaFeed.elements();e.hasMoreElements();)
  	  { Log.v(TAG,e.nextElement().toString()); }
      Log.v(TAG,"*************** END FEED LIST *****************");
    }
      
  	for(Enumeration<Feed> e=googleMetaFeed.elements();e.hasMoreElements();)
  	{ Feed feed=e.nextElement();
  	  if(DEBUG) Log.d(TAG,"*************** OPEN FEED: "+feed.toString()+" *****************");
//    Feed feed2=googleMetaFeed.getFeed(feed.getTitle());
      try { Vector<FeedEntry> entries=feed.load(); }
      catch(IOException ex) { ex.printStackTrace(); System.exit(0); }
      System.exit(0);
    }
  }

}